package com.framework.workflow.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zzg
 */
@ApiModel(value = "获取任务节点配置")
public class NodeProperty implements Serializable {
    @ApiModelProperty(value = "节点配置的处理人")
    private List<String> assignee;

    @ApiModelProperty(value = "节点配置的用户")
    private List<String> users;

    @ApiModelProperty(value = "节点配置的用户组")
    private List<String> groups;

    @ApiModelProperty(value = "是否会签节点")
    private boolean multi;

    @ApiModelProperty(value = "是否接受节点")
    private boolean isEnd;

    @ApiModelProperty(value = "策略： 1 同部门")
    private String strategy;

    @ApiModelProperty(value = "下一节点名称")
    private String nodeName;

    @JsonIgnore
    @ApiModelProperty(value = "任务定义编号")
    private String taskDefKey;

    @JsonIgnore
    @ApiModelProperty(value = "会签变量")
    private String collectionVariable;

    @JsonIgnore
    @ApiModelProperty(value = "是否触发错误消息事件节点")
    private boolean isFireEvent;

    public List<String> getAssignee() {
        return assignee;
    }

    public void setAssignee(String assignee) {
        if (StringUtils.isNotBlank(assignee)){
            if (null == this.assignee) {
                this.assignee = new ArrayList<>();
            }
            this.assignee.add(assignee);
        }

    }

    public List<String> getUsers() {
        return users;
    }

    public void setUsers(List<String> users) {
        if (null == this.users) {
            this.users = new ArrayList<>();
        }
        users = users.stream().filter(it -> StringUtils.isNotBlank(it)).collect(Collectors.toList());
        this.users.addAll(users);
    }

    public List<String> getGroups() {
        return groups;
    }

    public void setGroups(List<String> groups) {
        if (null == this.groups) {
            this.groups = new ArrayList<>();
        }
        groups = groups.stream().filter(it -> StringUtils.isNotBlank(it)).collect(Collectors.toList());
        this.groups.addAll(groups);
    }

    public boolean isMulti() {
        return multi;
    }

    public void setMulti(boolean multi) {
        this.multi = multi;
    }

    public boolean isEnd() {
        return isEnd;
    }

    public void setEnd(boolean end) {
        isEnd = end;
    }

    public String getTaskDefKey() {
        return taskDefKey;
    }

    public void setTaskDefKey(String taskDefkey) {
        this.taskDefKey = taskDefkey;
    }

    public String getCollectionVariable() {
        return collectionVariable;
    }

    public void setCollectionVariable(String collectionVariable) {
        this.collectionVariable = collectionVariable;
    }

    public String getStrategy() {
        return strategy;
    }

    public void setStrategy(String strategy) {
        this.strategy = strategy;
    }

    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public boolean isFireEvent() {
        return isFireEvent;
    }

    public void setFireEvent(boolean fireEvent) {
        isFireEvent = fireEvent;
    }
}
